package com.zhanghe.study.study_scala.oop

import scala.beans.BeanProperty

/**
 * 构造器
 * @author zh
 * @date 2021/5/1 21:07
 */
object TestConstructor {
  def main(args: Array[String]): Unit = {
    var person:Person = new Person("张三","123456","男")
  }

}

class Person private(var inName: String, val inCardNo: String) { // 主构造器，主构造器只能有一个

  inName = "100"
  @BeanProperty var name:String = inName
  @BeanProperty var cardNo:String = inCardNo
  @BeanProperty var sex:String = _


  println("构造器")

  def this(name:String,cardNo:String,sex:String){ // 辅助构造器可以有多个
    // 辅助构造器第一行必须显式的调用主构造器
    this(name,cardNo)
    this.sex = sex
    println("辅助构造器")
  }

}
